﻿using Autofac;
using Autofac.Integration.Mvc;
using log4net.Config;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;

namespace ConfigurationLearning
{
    public class Dependency
    {
        /// <summary>
        /// 注册业务层接口
        /// </summary>
        public static void RegisterType()
        {
            var builder = new ContainerBuilder();

            //设置日志log
            var logCfg = new FileInfo(HttpRuntime.AppDomainAppPath + "log4net.config");
            XmlConfigurator.ConfigureAndWatch(logCfg);
            builder.RegisterModule<LoggingModule>();

            builder.RegisterControllers(Assembly.GetExecutingAssembly());//注册mvc容器的实现  

            DependencyResolver.SetResolver(new AutofacDependencyResolver(builder.Build()));//注册MVC容器  
        }
    }
}